﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;

namespace Check_Printing_Solution
{
    public partial class ConfigurationForm : Form
    {
        PrintManager manager = new PrintManager();
        Customer selectedcustomer = new Customer();
        Bank bank = new Bank();
        IntegratedForm parentform = new IntegratedForm();

        public ConfigurationForm()
        {
            InitializeComponent();
            GetFontTypes();
        }

        public ConfigurationForm( Form form )
        {
            InitializeComponent();
            parentform = (IntegratedForm)form;
            GetFontTypes();
        }

        private void GetFontTypes()
        {
            AutoCompleteStringCollection fonts = new AutoCompleteStringCollection();
            foreach ( FontFamily font in System.Drawing.FontFamily.Families )
            {
                fonts.Add( font.Name );
            }
            NameFont.AutoCompleteSource = AutoCompleteSource.CustomSource;
            NameFont.AutoCompleteCustomSource = fonts;
            Address1Font.AutoCompleteSource = AutoCompleteSource.CustomSource;
            Address1Font.AutoCompleteCustomSource = fonts;
            Address2Font.AutoCompleteSource = AutoCompleteSource.CustomSource;
            Address2Font.AutoCompleteCustomSource = fonts;
            Address3Font.AutoCompleteSource = AutoCompleteSource.CustomSource;
            Address3Font.AutoCompleteCustomSource = fonts;
            Address4Font.AutoCompleteSource = AutoCompleteSource.CustomSource;
            Address4Font.AutoCompleteCustomSource = fonts;
            CheckNoFont.AutoCompleteSource = AutoCompleteSource.CustomSource;
            CheckNoFont.AutoCompleteCustomSource = fonts;
        }

        private void RefreshChequeTypes()
        {
            cmbChequeType.Text = "";

            cmbChequeType.DataSource = manager.GetAllChequeTypes();
            cmbChequeType.DisplayMember = "Name";
            cmbChequeType.ValueMember = "Id";

            if ( cmbChequeType.Items.Count != 0 )
            {
                btnSave.Enabled = true;
                TemplateLayout layout = manager.GetTemplateLayout( cmbChequeType.SelectedValue.ToString() );
                if ( layout != null )
                {
                    Address1Font.Text = layout.Address1Font;
                    Address1Size.Text = layout.Address1FontSize;
                    Address1X.Text = layout.Address1X;
                    Address1Y.Text = layout.Address1Y;

                    Address2Font.Text = layout.Address2Font;
                    Address2Size.Text = layout.Address2FontSize;
                    Address2X.Text = layout.Address2X;
                    Address2Y.Text = layout.Address2Y;

                    Address3Font.Text = layout.Address3Font;
                    Address3Size.Text = layout.Address3Size;
                    Address3X.Text = layout.Address3X;
                    Address3Y.Text = layout.Address3Y;

                    Address4Font.Text = layout.Address4Font;
                    Address4Size.Text = layout.Address4Size;
                    Address4X.Text = layout.Address4X;
                    Address4Y.Text = layout.Address4Y;

                    BankFont.Text = layout.BankFont;
                    BankSize.Text = layout.BankFontSize;
                    BankX.Text = layout.BankX;
                    BankY.Text = layout.BankY;
                    CheckNoFont.Text = layout.ChequeNumberFont;
                    CheckSize.Text = layout.ChequeNumberFontSize;
                    CheckNoX.Text = layout.ChequeNumberX;
                    CheckNoY.Text = layout.ChequeNumberY;
                    txtChequesPerPage.Text = layout.ChquesPerPage;
                    txtDepositSlips.Text = layout.DepositSlips;
                    txtDistanceBetweenCheques.Text = layout.DistanceBetweenCheques;
                    NameFont.Text = layout.NameFont;
                    NameSize.Text = layout.NameFontSize;
                    NameX.Text = layout.NameX;
                    NameY.Text = layout.NameY;
                    chkPrintBranch.Checked = layout.PrintBranch;
                    chkPrintBranchAddress.Checked = layout.PrintBranchAddress;
                    chkPrintChequeNos.Checked = layout.PrintChequeNos;
                    chkPrintCovers.Checked = layout.PrintCovers;
                    chkPrintNameAddress.Checked = layout.PrintNameAddress;
                    chkPrintNames.Checked = layout.PrintNames;
                    chkPrintStubNos.Checked = layout.PrintStubNos;

                    txtCoverNameFont.Text = layout.CoverNameFont;
                    txtCoverNameSize.Text = layout.CoverNameSize;
                    txtCoverNameX.Text = layout.CoverNameX;
                    txtCoverNameY.Text = layout.CoverNameY;

                    txtCoverAddress1Font.Text = layout.CoverAddress1Font;
                    txtCoverAddress1Size.Text = layout.CoverAddress1Size;
                    txtCoverAddress1X.Text = layout.CoverAddress1X;
                    txtCoverAddress1Y.Text = layout.CoverAddress1Y;

                    txtCoverAddress2Font.Text = layout.CoverAddress2Font;
                    txtCoverAddress2Size.Text = layout.CoverAddress2Size;
                    txtCoverAddress2X.Text = layout.CoverAddress2X;
                    txtCoverAddress2Y.Text = layout.CoverAddress2Y;

                    txtCoverAddress3Font.Text = layout.CoverAddress3Font;
                    txtCoverAddress3Size.Text = layout.CoverAddress3Size;
                    txtCoverAddress3X.Text = layout.CoverAddress3X;
                    txtCoverAddress3Y.Text = layout.CoverAddress3Y;

                    txtCoverAddress4Font.Text = layout.CoverAddress4Font;
                    txtCoverAddress4Size.Text = layout.CoverAddress4Size;
                    txtCoverAddress4X.Text = layout.CoverAddress4X;
                    txtCoverAddress4Y.Text = layout.CoverAddress4Y;

                    txtCoverTelephoneFont.Text = layout.CoverTelephoneFont;
                    txtCoverTelephoneSize.Text = layout.CoverTelephoneSize;
                    txtCoverTelephoneX.Text = layout.CoverTelephoneX;
                    txtCoverTelephoneY.Text = layout.CoverTelephoneY;

                    txtCountFont.Text = layout.ChequeCountFont;
                    txtCountFontSize.Text = layout.ChequeCountFontSize;
                    txtCountX.Text = layout.ChequeCountX;
                    txtCountY.Text = layout.ChequeCountY;

                    txtCoverCheckNoX.Text = layout.CoverCheckNoX;
                    txtCoverCheckNoY.Text = layout.CoverCheckNoY;
                    txtCoverCheckNoFont.Text = layout.CoverCheckNoFont;
                    txtCoverCheckNoSize.Text = layout.CoverCheckNoSize;

                    txtCoverCheckCountX.Text = layout.CoverCheckCountX;
                    txtCoverCheckCountY.Text = layout.CoverCheckCountY;
                    txtCoverCheckCountFont.Text = layout.CoverCheckCountFont;
                    txtCoverCheckCountSize.Text = layout.CoverCheckCountSize;

                    txtNumberChequesPerBook.Text = layout.NoChequesPerBook;
                    txtSeqNumberSize.Text = layout.SeqNumberSize;

                    chkBoldLine1Cheque.Checked = layout.BoldNameCheque;
                    chkBoldLine1Cover.Checked = layout.BoldNameCover;

                    txtStubX.Text = layout.StubX;
                    txtStubY.Text = layout.StubY;
                    txtStubFont.Text = layout.StubFont;
                    txtStubSize.Text = layout.StubSize;

                    txtCoverCount.Text = layout.CoverCount.ToString();

                    chkPrintStubNos2.Checked = layout.PrintStubNos2;

                    chkSkip.Checked = layout.Skip;

                    chkBoldLine2Cheque.Checked = layout.BoldLine2Cheque;
                    chkBoldLine3Cheque.Checked = layout.BoldLine3Cheque;
                    chkBoldLine4Cheque.Checked = layout.BoldLine4Cheque;
                    chkItalicLine1Cheque.Checked = layout.ItalicLine1Cheque;
                    chkItalicLine2Cheque.Checked = layout.ItalicLine2Cheque;
                    chkItalicLine3Cheque.Checked = layout.ItalicLine3Cheque;
                    chkItalicLine4Cheque.Checked = layout.ItalicLine4Cheque;

                    chkItalicLine1Cover.Checked = layout.ItalicLine1Cover;
                    chkItalicLine2Cover.Checked = layout.ItalicLine2Cover;
                    chkItalicLine3Cover.Checked = layout.ItalicLine3Cover;
                    chkItalicLine4Cover.Checked = layout.ItalicLine4Cover;

                    chkPrintDearCustomer.Checked = layout.PrintDearCustomer;

                    txtBranchNumberSize.Text = layout.BranchNumberSize.ToString();
                    txtTransitNumberSize.Text = layout.TransitNumberSize.ToString();
                    txtAccountNumberSize.Text = layout.AccountNumberSize.ToString();
                    txtTransitCodeSize.Text = layout.TransitCodeSize.ToString();

                    txtHeight.Text = ( Convert.ToDouble( layout.PaperHeight.ToString() ) / 100 ).ToString();
                    txtWidth.Text = ( Convert.ToDouble( layout.PaperWidth.ToString() ) / 100 ).ToString();
                    cmbTray.Text = layout.Tray;

                    PrintDocument template = new PrintDocument();
                    cmbTray.Items.Clear();
                    foreach ( PaperSource ps in template.PrinterSettings.PaperSources )
                    {
                        cmbTray.Items.Add( ps.SourceName );
                    }

                    if ( layout.NoCopies == 1 )
                    {
                        rdo1.Checked = true;
                    }
                    else if ( layout.NoCopies == 2 )
                    {
                        rdo2.Checked = true;
                    }
                    else if ( layout.NoCopies == 3 )
                    {
                        rdo3.Checked = true;
                    }
                    else if ( layout.NoCopies == 0 )
                    {
                        rdoNone.Checked = true;
                    }

                    if ( layout.Landscape )
                    {
                        rbLandscape.Checked = true;
                        rbPortrait.Checked = false;
                    }
                    else
                    {
                        rbPortrait.Checked = true;
                        rbLandscape.Checked = false;
                    }
                }
            }
            else
            {
                btnSave.Enabled = false;
            }
        }

        private void ConfigurationForms_Load( object sender, EventArgs e )
        {
            this.AcceptButton = btnSave;

            RefreshChequeTypes();
        }

        private void btnSave_Click( object sender, EventArgs e )
        {
            TemplateLayout layout = new TemplateLayout();
            layout.Address1Font = Address1Font.Text;
            layout.Address1FontSize = Address1Size.Text;
            layout.Address1X = Address1X.Text;
            layout.Address1Y = Address1Y.Text;
            layout.Address2Font = Address2Font.Text;
            layout.Address2FontSize = Address2Size.Text;
            layout.Address2X = Address2X.Text;
            layout.Address2Y = Address2Y.Text;

            layout.Address3Font = Address3Font.Text;
            layout.Address3Size = Address3Size.Text;
            layout.Address3X = Address3X.Text;
            layout.Address3Y = Address3Y.Text;

            layout.Address4Font = Address4Font.Text;
            layout.Address4Size = Address4Size.Text;
            layout.Address4X = Address4X.Text;
            layout.Address4Y = Address4Y.Text;

            layout.BankFont = BankFont.Text;
            layout.BankFontSize = BankSize.Text;
            layout.BankX = BankX.Text;
            layout.BankY = BankY.Text;
            layout.ChequeNumberFont = CheckNoFont.Text;
            layout.ChequeNumberFontSize = CheckSize.Text;
            layout.ChequeNumberX = CheckNoX.Text;
            layout.ChequeNumberY = CheckNoY.Text;
            layout.ChquesPerPage = txtChequesPerPage.Text;
            layout.DepositSlips = txtDepositSlips.Text;
            layout.DistanceBetweenCheques = txtDistanceBetweenCheques.Text;
            layout.Id = Guid.NewGuid().ToString();
            layout.NameFont = NameFont.Text;
            layout.NameFontSize = NameSize.Text;
            layout.NameX = NameX.Text;
            layout.NameY = NameY.Text;
            layout.PrintBranch = chkPrintBranch.Checked;
            layout.PrintBranchAddress = chkPrintBranchAddress.Checked;
            layout.PrintChequeNos = chkPrintChequeNos.Checked;
            layout.PrintCovers = chkPrintCovers.Checked;
            layout.PrintNameAddress = chkPrintNameAddress.Checked;
            layout.PrintNames = chkPrintNames.Checked;
            layout.PrintStubNos = chkPrintStubNos.Checked;
            layout.ChequeTypeId = cmbChequeType.SelectedValue.ToString();

            layout.CoverNameFont = txtCoverNameFont.Text;
            layout.CoverNameSize = txtCoverNameSize.Text;
            layout.CoverNameX = txtCoverNameX.Text;
            layout.CoverNameY = txtCoverNameY.Text;

            layout.CoverAddress1Font = txtCoverAddress1Font.Text;
            layout.CoverAddress1Size = txtCoverAddress1Size.Text;
            layout.CoverAddress1X = txtCoverAddress1X.Text;
            layout.CoverAddress1Y = txtCoverAddress1Y.Text;

            layout.CoverAddress2Font = txtCoverAddress2Font.Text;
            layout.CoverAddress2Size = txtCoverAddress2Size.Text;
            layout.CoverAddress2X = txtCoverAddress2X.Text;
            layout.CoverAddress2Y = txtCoverAddress2Y.Text;

            layout.CoverAddress3Font = txtCoverAddress3Font.Text;
            layout.CoverAddress3Size = txtCoverAddress3Size.Text;
            layout.CoverAddress3X = txtCoverAddress3X.Text;
            layout.CoverAddress3Y = txtCoverAddress3Y.Text;

            layout.CoverAddress4Font = txtCoverAddress4Font.Text;
            layout.CoverAddress4Size = txtCoverAddress4Size.Text;
            layout.CoverAddress4X = txtCoverAddress4X.Text;
            layout.CoverAddress4Y = txtCoverAddress4Y.Text;

            layout.CoverTelephoneFont = txtCoverTelephoneFont.Text;
            layout.CoverTelephoneSize = txtCoverTelephoneSize.Text;
            layout.CoverTelephoneX = txtCoverTelephoneX.Text;
            layout.CoverTelephoneY = txtCoverTelephoneY.Text;

            layout.ChequeCountFont = txtCountFont.Text;
            layout.ChequeCountFontSize = txtCountFontSize.Text;
            layout.ChequeCountX = txtCountX.Text;
            layout.ChequeCountY = txtCountY.Text;

            layout.CoverCheckNoX = txtCoverCheckNoX.Text;
            layout.CoverCheckNoY = txtCoverCheckNoY.Text;
            layout.CoverCheckNoFont = txtCoverCheckNoFont.Text;
            layout.CoverCheckNoSize = txtCoverCheckNoSize.Text;

            layout.CoverCheckCountX = txtCoverCheckCountX.Text;
            layout.CoverCheckCountY = txtCoverCheckCountY.Text;
            layout.CoverCheckCountFont = txtCoverCheckCountFont.Text;
            layout.CoverCheckCountSize = txtCoverCheckCountSize.Text;

            layout.NoChequesPerBook = txtNumberChequesPerBook.Text;
            layout.SeqNumberSize = txtSeqNumberSize.Text;

            layout.BoldNameCheque = chkBoldLine1Cheque.Checked;
            layout.BoldNameCover = chkBoldLine1Cover.Checked;

            layout.StubX = txtStubX.Text;
            layout.StubY = txtStubY.Text;
            layout.StubFont = txtStubFont.Text;
            layout.StubSize = txtStubSize.Text;

            layout.PrintStubNos2 = chkPrintStubNos2.Checked;

            layout.CoverCount = Convert.ToInt32( txtCoverCount.Text );

            layout.Skip = chkSkip.Checked;

            layout.BoldLine2Cheque = chkBoldLine2Cheque.Checked;
            layout.BoldLine3Cheque = chkBoldLine3Cheque.Checked;
            layout.BoldLine4Cheque = chkBoldLine4Cheque.Checked;
            layout.ItalicLine1Cheque = chkItalicLine1Cheque.Checked;
            layout.ItalicLine2Cheque = chkItalicLine2Cheque.Checked;
            layout.ItalicLine3Cheque = chkItalicLine3Cheque.Checked;
            layout.ItalicLine4Cheque = chkItalicLine4Cheque.Checked;

            layout.ItalicLine1Cover = chkItalicLine1Cover.Checked;
            layout.ItalicLine2Cover = chkItalicLine2Cover.Checked;
            layout.ItalicLine3Cover = chkItalicLine3Cover.Checked;
            layout.ItalicLine4Cover = chkItalicLine4Cover.Checked;

            layout.PrintDearCustomer = chkPrintDearCustomer.Checked;

            layout.BranchNumberSize = Convert.ToInt32( txtBranchNumberSize.Text );
            layout.TransitNumberSize = Convert.ToInt32( txtTransitNumberSize.Text );
            layout.AccountNumberSize = Convert.ToInt32( txtAccountNumberSize.Text );
            layout.TransitCodeSize = Convert.ToInt32( txtTransitCodeSize.Text );

            layout.PaperHeight = Convert.ToInt32( Convert.ToDouble( txtHeight.Text ) * 100 );
            layout.PaperWidth = Convert.ToInt32( Convert.ToDouble( txtWidth.Text ) * 100 );
            layout.Tray = cmbTray.Text;

            if ( rdo1.Checked )
            {
                layout.NoCopies = 1;
            }
            else if ( rdo2.Checked )
            {
                layout.NoCopies = 2;
            }
            else if ( rdo3.Checked )
            {
                layout.NoCopies = 3;
            }
            else if ( rdoNone.Checked )
            {
                layout.NoCopies = 0;
            }

            if ( rbLandscape.Checked )
            {
                layout.Landscape = true;
            }
            else
            {
                layout.Landscape = false;
            }

            manager.SaveTemplate( layout, cmbChequeType.SelectedValue.ToString() );

            toolStripStatusLabel2.Text = DateTime.Now.ToShortDateString() + " - " + DateTime.Now.ToLongTimeString();
        }

        private void btnClose_Click( object sender, EventArgs e )
        {
            this.Close();
        }

        private void cmbBanks_SelectedIndexChanged( object sender, EventArgs e )
        {
            RefreshChequeTypes();
        }

        private void cmbChequeType_SelectedIndexChanged( object sender, EventArgs e )
        {
            TemplateLayout layout = manager.GetTemplateLayout( cmbChequeType.SelectedValue.ToString() );
            if ( layout != null )
            {
                chkBoldLine1Cheque.Checked = layout.BoldNameCheque;

                Address1Font.Text = layout.Address1Font;
                Address1Size.Text = layout.Address1FontSize;
                Address1X.Text = layout.Address1X;
                Address1Y.Text = layout.Address1Y;
                Address2Font.Text = layout.Address2Font;
                Address2Size.Text = layout.Address2FontSize;
                Address2X.Text = layout.Address2X;
                Address2Y.Text = layout.Address2Y;
                BankFont.Text = layout.BankFont;
                BankSize.Text = layout.BankFontSize;
                BankX.Text = layout.BankX;
                BankY.Text = layout.BankY;
                CheckNoFont.Text = layout.ChequeNumberFont;
                CheckSize.Text = layout.ChequeNumberFontSize;
                CheckNoX.Text = layout.ChequeNumberX;
                CheckNoY.Text = layout.ChequeNumberY;
                txtChequesPerPage.Text = layout.ChquesPerPage;
                txtDepositSlips.Text = layout.DepositSlips;
                txtDistanceBetweenCheques.Text = layout.DistanceBetweenCheques;
                NameFont.Text = layout.NameFont;
                NameSize.Text = layout.NameFontSize;
                NameX.Text = layout.NameX;
                NameY.Text = layout.NameY;
                chkPrintBranch.Checked = layout.PrintBranch;
                chkPrintBranchAddress.Checked = layout.PrintBranchAddress;
                chkPrintChequeNos.Checked = layout.PrintChequeNos;
                chkPrintCovers.Checked = layout.PrintCovers;
                chkPrintNameAddress.Checked = layout.PrintNameAddress;
                chkPrintNames.Checked = layout.PrintNames;
                chkPrintStubNos.Checked = layout.PrintStubNos;

                txtCoverAddress3Font.Text = layout.CoverAddress3Font;

                txtCoverNameFont.Text = layout.CoverNameFont;
                txtCoverNameSize.Text = layout.CoverNameSize;
                txtCoverNameX.Text = layout.CoverNameX;
                txtCoverNameY.Text = layout.CoverNameY;

                txtCoverAddress1Font.Text = layout.CoverAddress1Font;
                txtCoverAddress1Size.Text = layout.CoverAddress1Size;
                txtCoverAddress1X.Text = layout.CoverAddress1X;
                txtCoverAddress1Y.Text = layout.CoverAddress1Y;

                txtCoverAddress2Font.Text = layout.CoverAddress2Font;
                txtCoverAddress2Size.Text = layout.CoverAddress2Size;
                txtCoverAddress2X.Text = layout.CoverAddress2X;
                txtCoverAddress2Y.Text = layout.CoverAddress2Y;

                Address3Font.Text = layout.Address3Font;
                Address3Size.Text = layout.Address3Size;
                Address3X.Text = layout.Address3X;
                Address3Y.Text = layout.Address3Y;

                Address4Font.Text = layout.Address4Font;
                Address4Size.Text = layout.Address4Size;
                Address4X.Text = layout.Address4X;
                Address4Y.Text = layout.Address4Y;

                txtCoverTelephoneFont.Text = layout.CoverTelephoneFont;
                txtCoverTelephoneSize.Text = layout.CoverTelephoneSize;
                txtCoverTelephoneX.Text = layout.CoverTelephoneX;
                txtCoverTelephoneY.Text = layout.CoverTelephoneY;

                txtCountFont.Text = layout.ChequeCountFont;
                txtCountFontSize.Text = layout.ChequeCountFontSize;
                txtCountX.Text = layout.ChequeCountX;
                txtCountY.Text = layout.ChequeCountY;

                txtCoverCheckNoX.Text = layout.CoverCheckNoX;
                txtCoverCheckNoY.Text = layout.CoverCheckNoY;
                txtCoverCheckNoFont.Text = layout.CoverCheckNoFont;
                txtCoverCheckNoSize.Text = layout.CoverCheckNoSize;

                txtCoverCheckCountX.Text = layout.CoverCheckCountX;
                txtCoverCheckCountY.Text = layout.CoverCheckCountY;
                txtCoverCheckCountFont.Text = layout.CoverCheckCountFont;
                txtCoverCheckCountSize.Text = layout.CoverCheckCountSize;
                txtCoverAddress4X.Text = layout.CoverAddress4X;
                txtNumberChequesPerBook.Text = layout.NoChequesPerBook;
                txtSeqNumberSize.Text = layout.SeqNumberSize;

                txtStubX.Text = layout.StubX;
                txtStubY.Text = layout.StubY;
                txtStubFont.Text = layout.StubFont;
                txtStubSize.Text = layout.StubSize;

                chkPrintStubNos2.Checked = layout.PrintStubNos2;

                txtCoverCount.Text = layout.CoverCount.ToString();

                chkSkip.Checked = layout.Skip;

                chkBoldLine2Cheque.Checked = layout.BoldLine2Cheque;
                chkBoldLine3Cheque.Checked = layout.BoldLine3Cheque;
                chkBoldLine4Cheque.Checked = layout.BoldLine4Cheque;
                chkItalicLine1Cheque.Checked = layout.ItalicLine1Cheque;
                chkItalicLine2Cheque.Checked = layout.ItalicLine2Cheque;
                chkItalicLine3Cheque.Checked = layout.ItalicLine3Cheque;
                chkItalicLine4Cheque.Checked = layout.ItalicLine4Cheque;

                chkItalicLine1Cover.Checked = layout.ItalicLine1Cover;
                chkItalicLine2Cover.Checked = layout.ItalicLine2Cover;
                chkItalicLine3Cover.Checked = layout.ItalicLine3Cover;
                chkItalicLine4Cover.Checked = layout.ItalicLine4Cover;

                txtCoverAddress4Y.Text = layout.CoverAddress4Y;

                txtHeight.Text = ( Convert.ToDouble( layout.PaperHeight.ToString() ) / 100 ).ToString();
                txtWidth.Text = ( Convert.ToDouble( layout.PaperWidth.ToString() ) / 100 ).ToString();
                cmbTray.Text = layout.Tray;

                chkPrintDearCustomer.Checked = layout.PrintDearCustomer;

                txtBranchNumberSize.Text = layout.BranchNumberSize.ToString();
                txtTransitNumberSize.Text = layout.TransitNumberSize.ToString();
                txtAccountNumberSize.Text = layout.AccountNumberSize.ToString();
                txtTransitCodeSize.Text = layout.TransitCodeSize.ToString();

                if ( layout.NoCopies == 1 )
                {
                    rdo1.Checked = true;
                }
                else if ( layout.NoCopies == 2 )
                {
                    rdo2.Checked = true;
                }
                else if ( layout.NoCopies == 3 )
                {
                    rdo3.Checked = true;
                }
                else if ( layout.NoCopies == 0 )
                {
                    rdoNone.Checked = true;
                }

                if ( layout.Landscape )
                {
                    rbLandscape.Checked = true;
                    rbPortrait.Checked = false;
                }
                else
                {
                    rbPortrait.Checked = true;
                    rbLandscape.Checked = false;
                }
            }
        }

        private void btnPrint_Click( object sender, EventArgs e )
        {
            parentform.Print( cmbChequeType.SelectedValue.ToString() );
        }

        private void label16_Click( object sender, EventArgs e )
        {

        }

        private void chkPrintCovers_CheckedChanged( object sender, EventArgs e )
        {
            if ( chkPrintCovers.Checked )
            {
                txtCoverCount.Enabled = true;
            }
            else
            {
                txtCoverCount.Enabled = false;
            }
        }

        private void groupBox3_Enter( object sender, EventArgs e )
        {

        }

        private void txtSeqCopy_TextChanged( object sender, EventArgs e )
        {
            txtSeqNumberSize.Text = txtSeqCopy.Text;
        }

        private void txtSeqNumberSize_TextChanged( object sender, EventArgs e )
        {
            txtSeqCopy.Text = txtSeqNumberSize.Text;
        }
    }
}
